<?php
namespace PartnerAdmin\Model;
use Think\Model;
class UsersModel extends Model {
    public function search($perPage = 8)
    {
        /*************搜索*********************/
        $keyword = I('get.keyword');
        $where = array();
        if($keyword)
        {
            $where['nickname'] = array('like','%'.$keyword.'%');
        }
        $where['partner_id'] =session('id');

        /*************翻页*******************/
        // $count = $this->count();
        // $pageObj = new \Think\Page($count,$perPage);
        // $pageString = $pageObj->show();

        // $data = $this->where($where)
        //         ->order('id')
        //         ->limit($pageObj->firstRow.','.$pageObj->listRows)
        //         ->select();
        $data = $this->where($where)->order('id asc')->select();
        foreach($data as $k=>&$v){
            $v['account'] = substr_replace($v['account'],'****',3,4);
            if($v['partner_id'] != 0){
                $partner = D('Partners')->where('id='.$v['partner_id'])->getField('nickname'); 
                $v['partner'] = $partner; 
            }   
        }
        
        //var_dump($data);die;
        return array(
            'users'     =>  $data,

            );
    }
}